<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no"/>
    <title>更改密码</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../css/common.css"/>
    <style>
        body {
            background: #f3f3f3;
            font-size: 16px;
        }

        .aui-icon-left {
            padding-left: 10px;
        }

        .aui-slide-page-active {
            background: #327afa;
        }

        .aui-input-addon{
            padding-left: 15px !important;
        }
        .myBtn {
            position: fixed;
            bottom: 0;
        }

        .spanOk {
            display: block;
            border-radius: 50%;
            width: 50px;
            height: 50px;
            background: #ff3333;
            position: relative;
            margin: 0 auto;
            margin-bottom: 10px;
        }

        .spanOk:before {
            position: absolute;
            content: "\e645";
            left: 26%;
            top: 10%;
            color: #fff;
            font-size: 25px;
        }

        .ok {
            text-align: center;
        }

        .result {
            display: none;
        }

        .result .aui-btn-block{
            width: 70%;
            height:40px;
            line-height:40px;
            margin:0 auto;
        }
    </style>
</head>
<body>
<header class="aui-bar aui-bar-nav aui-border-b" style="margin-bottom: 15px;">
    <div class="aui-pull-left aui-iconfont aui-icon-left icon-left-coler" tapmode onclick="closeWin()"></div>
    <div class="aui-title">更改密码</div>
</header>


<div class="contain aui-content">
    <div class="aui-form">
        <div class="aui-input-row">
            <label class="aui-input-addon">原密码</label>
            <input type="password" id="passwordOld" class="aui-input" value=""  placeholder="请输入原密码" />
        </div>
        <div class="aui-input-row">
            <label class="aui-input-addon">新密码</label>
            <input type="password" id="passwordNew" class="aui-input" value=""  placeholder="请输入新密码" />
        </div>
        <div class="aui-input-row">
            <label class="aui-input-addon">再确认</label>
            <input type="password" id="passwordRepeat" class="aui-input" value="" placeholder="请确认新密码" />
        </div>
    </div>
    <div class="myBtn" tapmode onclick="modifyPassword()">确定</div>
</div>

<!-- 控制影藏显示 -->
<div class="result">
    <div class="ok">
        <span class="aui-iconfont aui-icon-check spanOk"></span>
        <br>
        <p>修改成功</p>
        <br>
    </div>
    <div class="aui-btn aui-btn-primary aui-btn-block aui-btn-outlined" onclick="openIndex();">
        去首页
    </div>
</div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/jquery-1.11.3.js"></script>
<script type="text/javascript">
    apiready = function () {
        api.parseTapmode();
        var mobile = api.pageParam.mobile;
        var header = $api.dom('header');
        var footer = $api.dom('footer');
        $api.fixIos7Bar(header);
        
        getStorageAll();

        $('.result').css({'padding-top': $api.offset($api.dom('body')).h*1/11+'px'});
    }
    /*function changePaw() {
     $(".contain").css({"display": "none"});
     $(".result").css({"display": "block"});
     }*/

    //修改密码
    function modifyPassword() {
        var passwordOld = $('#passwordOld').val();
        var passwordNew = $('#passwordNew').val();
        var passwordRepeat = $('#passwordRepeat').val();
        if (passwordOld == '' || passwordNew == '' || passwordRepeat == '') {
            api.toast({
                msg: '密码不能为空',
                duration: 2000,
                location: 'bottom'
            });
            return false;
        }
        if (passwordNew != passwordRepeat) {
            api.toast({
                msg: '新密码不一致',
                duration: 2000,
                location: 'bottom'
            });
            return false;
        }
        if (passwordNew == passwordOld) {
            api.toast({
                msg: '新密码和旧密码不能一样',
                duration: 2000,
                location: 'bottom'
            });
            return false;
        }

        showLoading();
        data = {
            passwordOld: passwordOld,
            passwordNew: passwordNew,
            userName: user_name,
        };
        url = "User/modifyPassword";
        ajaxRequest(url, 'post', data, function (ret, err) {
            if (ret.status == 1) {
                $(".contain").css({"display": "none"});
                $(".result").css({"display": "block"});
            } else {
                api.toast({
                    msg: ret.msg,
                    duration: 2000,
                    location: 'bottom'
                });
            }
        });
        hideLoading();
    }

    //回到首页
    function openIndex() {
        api.closeToWin({
            name: 'root',
            animation: {
                type: 'flip',
                subType: 'from_bottom',
                duration: 500
            }
        });
    }
</script>
</html>
